package main;

import com.opensymphony.xwork2.ActionSupport;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import member.MemberModel;

import java.io.IOException;
import java.io.Reader;

public class memberIdCheckAction extends ActionSupport {
	public static Reader reader;  
	public static SqlMapClient sqlMapper; 
	
	private MemberModel resultClass; 
	
	private String id;
	
	private int chkId;
	
	
	public memberIdCheckAction() throws IOException {
		reader = Resources.getResourceAsReader("sqlMapConfig.xml"); 
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
		reader.close();
	}
	
	public String execute() throws Exception {
		/*System.out.println(getId());*/
		
		resultClass = new MemberModel();
		
		if(getId() != null){
			resultClass = (MemberModel) sqlMapper.queryForObject("member.searchpw", getId());		
		}
		
		
		if(resultClass == null) {
			chkId = 0; 
		}
		else {
			chkId = 1; 
		}
		System.out.println(getId());
	
		return SUCCESS;
		
	}

	public static Reader getReader() {
		return reader;
	}

	public static void setReader(Reader reader) {
		memberIdCheckAction.reader = reader;
	}

	public static SqlMapClient getSqlMapper() {
		return sqlMapper;
	}

	public static void setSqlMapper(SqlMapClient sqlMapper) {
		memberIdCheckAction.sqlMapper = sqlMapper;
	}

	public MemberModel getResultClass() {
		return resultClass;
	}

	public void setResultClass(MemberModel resultClass) {
		this.resultClass = resultClass;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getChkId() {
		return chkId;
	}

	public void setChkId(int chkId) {
		this.chkId = chkId;
	}


}
